package com.program.cloudmanagesystem.hotel.persistence;
import com.program.cloudmanagesystem.hotel.domain.Hotel;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository

public interface HotelMapper {
    @Select("select * from hotel")
    List<Hotel> showHotels();
    @Select("select * from hotel where hotel.id = #{id}")
    Hotel searchHotel(String id);
    @Select("SELECT * FROM hotel WHERE hotel.name LIKE CONCAT('%', #{name}, '%')")
    List<Hotel> searchHotelByName(String name);
    @Insert("insert into hotel(id,name,maxcapacity ,maxparking,maxcheck,location,information) values (#{id},#{name},#{maxcapacity},#{maxparking},#{maxcheck},#{location},#{information})")
    void insertHotel(@Param("id") String id,@Param("name") String name,@Param("maxcapacity") String maxcapacity,@Param("maxparking") String maxparking,@Param("maxcheck") String maxcheck,@Param("location") String location,@Param("information") String information);
    @Delete("delete from hotel where id = #{id}")
    void deleteHotel(String id);
    @Update("update hotel set name = #{name},maxcapacity = #{maxcapacity},maxparking = #{maxparking},maxcheck = #{maxcheck},location = #{location},information = #{information},score = #{score} where hotel.id = #{id}")
    void updateData(@Param("id") String id,@Param("name") String name,@Param("maxcapacity") String maxcapacity,@Param("maxparking") String maxparking,@Param("maxcheck") String maxcheck,@Param("location") String location,@Param("information") String information,@Param("score") String score);
      @Update("update hotel set score = #{score} where hotel.id = #{id}")
    void updateScore(@Param("id") String id,@Param("score") String score);
    @Update("update hotel set capacity = #{capacity},parking = #{parking},`check` = #{check} where hotel.id = #{id}")
    void updateNow(@Param("id") String id, @Param("capacity") String capacity, @Param("parking") String parking, @Param("check") String check);

}
